/**
 * 
 * @param id //省份 table Id
 */
operateLargeTypeId=null;
operateLargeTypeName=null;
operateTypeId=null;
operateTypeName=null;

function getoperateLarge(id){
	$.ajax({
		type : "get",
		async:false,
		datatype : "json",
		url : "../operLargeType/find/all",
		success : function(data) {
					var rst = JSON.parse(data);
					var obj = DealAndShowMsg(data,false,false);
					loadOperateLargeTable(rst,id);
					
		}	
	});	
}
function loadOperateLargeTable(json,id){
	$("table[id='"+id+"'] tbody").empty();
	
	if(json.result.data.length>4){
		$("table[id='"+id+"'] thead").html("<th>经营大类</th><th>操作</th><th>经营大类</th><th>操作</th><th>经营大类</th><th>操作</th><th>经营大类</th><th>操作</th>");

	for ( var i = 0; i < json.result.data.length; i++) {
		if((i%4)==0){
			$("table[id='"+id+"'] tbody").append("<tr></tr>");
		}		var pId=getHeadIndexValue(i, json, "id");
		var pName=getHeadIndexValue(i, json, "name");
		var htm="<td>"+pName+"</td><td><input class='common_btn' type='button' value='选择' onclick = \"chooseOperateLargeType("+pId+",'"+pName+"')\"></td>	";
		$("table[id='"+id+"'] tbody tr:last").append(htm)
		
		}
	}else{
		
		$("table[id='"+id+"'] thead").html("<th>经营大类</th><th>操作</th>");

		$("table[id='"+id+"'] tbody").append("<tr></tr>");
		for ( var i = 0; i < json.result.data.length; i++) {
			var pId=getHeadIndexValue(i, json, "id");
			var pName=getHeadIndexValue(i, json, "name");
			var htm="<td>"+pName+"</td><td><input class='common_btn' type='button' value='选择' onclick = \"chooseOperateLargeType("+pId+",'"+pName+"')\"></td>	";
			$("table[id='"+id+"'] tbody tr:last").append(htm)
			
			}
		
		var count= 4- $("table[id='"+id+"'] tbody tr:last").children("td").length;
		for ( var j = 0; j < count; j++) {
			$("table[id='"+id+"'] tbody tr:last").append("<td></td>");
			
		}
	}		
}



function getOperateType(tableId){
	$.ajax({
		type : "get",
		async:false,
		datatype : "json",
		url : "../operateType/find/operateLargeTypeId/"+operateLargeTypeId,
		success : function(data) {
					var rst = JSON.parse(data);
					loadOperateTypeTable(rst,tableId);
					
		}	
	});
}

function loadOperateTypeTable(json,id){
	$("table[id='"+id+"'] tbody").empty();
	if(json.result.data.length>4){
		$("table[id='"+id+"'] thead").html("<th>经营小类</th><th>操作</th><th>经营小类</th><th>操作</th><th>经营小类</th><th>操作</th><th>经营小类</th><th>操作</th>");

	for ( var i = 0; i < json.result.data.length; i++) {
		
		if((i%4)==0){
			$("table[id='"+id+"'] tbody").append("<tr></tr>");
		}		
		var cId=getHeadIndexValue(i, json, "id");
		var cName=getHeadIndexValue(i, json, "name");
		var htm="<td>"+cName+"</td><td><input class='common_btn' type='button' value='选择' onclick = \"chooseOperateType("+cId+",'"+cName+"')\"></td>	";
		$("table[id='"+id+"'] tbody tr:last").append(htm);
		
	}
	var count= 8- $("table[id='"+id+"'] tbody tr:last").children("td").length;
	for ( var j = 0; j < count; j++) {
		$("table[id='"+id+"'] tbody tr:last").append("<td></td>");
		
	}
	}else{
		$("table[id='"+id+"'] thead").html("<th>经营小类</th><th>操作</th>");
	
		for ( var i = 0; i < json.result.data.length; i++) {
				$("table[id='"+id+"'] tbody").append("<tr></tr>");		
			var cId=getHeadIndexValue(i, json, "id");
			var cName=getHeadIndexValue(i, json, "name");
			var htm="<td>"+cName+"</td><td><input class='common_btn' type='button' value='选择' onclick = \"chooseOperateType("+cId+",'"+cName+"')\"></td>	";
			$("table[id='"+id+"'] tbody tr:last").append(htm);
	}
		
	
	}
	}
